package com.e3roid.examples;

import com.e3roid.E3Activity;
import com.e3roid.E3Engine;
import com.e3roid.E3Scene;
import com.e3roid.script.lua.LuaScriptCanvas;
import com.e3roid.script.lua.LuaScriptEngine;

/**
 * Example of Using LuaScriptCanvas.
 *
 */
public class ScriptingLuaCanvasExample extends E3Activity {

	private final static int WIDTH  = 320;
	private final static int HEIGHT = 480;

	private LuaScriptCanvas luaCanvas;

	@Override
	public E3Engine onLoadEngine() {
		E3Engine engine = new E3Engine(this, WIDTH, HEIGHT);
		engine.requestFullScreen();
		engine.requestPortrait();
		return engine;
	}

	@Override
	public E3Scene onLoadScene() {
		E3Scene scene = new E3Scene();
		scene.getTopLayer().add(luaCanvas);
		return scene;
	}

	/**
	 * Create canvas from lua script.
	 */
	@Override
	public void onLoadResources() {
		LuaScriptEngine luaEngine = LuaScriptEngine.loadFromAsset("canvas.lua", this);
		luaCanvas = new LuaScriptCanvas(luaEngine, this);
	}
}